import {
    mountElement
} from "./mount"
import {
    isSameComponent
} from "./utils"
import {
    unMountNode
} from "./dom"
import {
    updateComponent
} from "./update"

export default function diffComponent(virtualDOM, oldVirtualDOM, oldDOM, container) {
    const oldComponent = oldVirtualDOM.component
    if (isSameComponent(virtualDOM, oldComponent)) {
        updateComponent(virtualDOM, oldComponent, container, oldDOM)
    } else {
        mountElement(virtualDOM, container)
        unMountNode(oldDOM)
    }
}